package GuessNumber;

import static java.lang.Thread.currentThread;

/**
 * @Author mao
 * @Date 2025/11/17
 * @Description 数字生成线程
 */
class NumberGenerator implements Runnable {
    private final NumberSync numberSync;

    public NumberGenerator(NumberSync numberSync) {
        this.numberSync = numberSync;
    }

    @Override
    public void run() {
        // 生成1-100的随机数
        int randomNum = (int) (Math.random() * 100) + 1;
        System.out.print(currentThread().getName()+"@ ");
        System.out.println("生成的随机数是: " + randomNum);

        numberSync.setTargetNumber(randomNum);
    }
}
